<?php
$auth = Auth::getAuth('current_user');
$db = new Database;
$fs = new functions;
$search = new Search();
$user_id = $auth['id'];
if(isset($_POST['action'])){

	$date = $fs->currentDateTime();
	switch($_POST['action']){
		
		case "getRequest":
			$id = $_POST['id'];
			$search_value = $_POST['search_value'];
			$field = $_POST['field'];
			$start = $_POST['start'];
			$date_field = $_POST['date_field'];
            $date_from = $_POST['date_from'];
            $date_to = $_POST['date_to'];
			if($date_field!="0" && $date_from!="" && $date_to!=""){
            	$obj = array("date_range"=>"1",
            				"date_field"=>$date_field,
            				"date_from"=>$date_from,
            				"date_to"=>$date_to);
            	$obj = json_decode(json_encode($obj),true);
			}
			$result = $search->getManyRequest($search_value,$field,$id,$start,10,$obj);
			echo json_encode($result);
			// echo $result;
			break;
		case "getRequestDataTable":
			$id = $_POST['id'];
			$search_value = $_POST['search_value'];
			$field = $_POST['field'];
			$start = $_POST['iDisplayStart'];
			$date_field = $_POST['date_field'];
            $date_from = $_POST['date_from'];
            $date_to = $_POST['date_to']; 
            $obj = array();
			if($date_field!="0" && $date_from!="" && $date_to!=""){
            	$obj = array("date_range"=>"1",
            				"date_field"=>$date_field,
            				"date_from"=>$date_from,

            				"date_to"=>$date_to);
            	$obj = json_decode(json_encode($obj),true);
			}
			if($_POST['column-sort']!=""){
				$obj['column-sort'] = $_POST['column-sort'];
				$obj['column-sort-type'] = $_POST['column-sort-type'];
			}
			
			if(isset($_POST['multi_search'])){
				$multi_search = "";
				$ctrSpec = 0;$ctr = 0;
				$multi_search_arr = json_decode($_POST['multi_search'],true);
				foreach ($multi_search_arr as $value) {
					$ctr++;
					if($value['search_field']=="0"){
						$search_value = $value['search_value'];
						$field = $value['search_field'];
					}else{
						$ctrSpec++;
						if($ctrSpec == 1){
							$multi_search .= " AND (";
						}
						if ($value['search_field'] == "Requestor") {
			                $multi_search .= " (u.first_name LIKE '%" . $value['search_value'] . "%' OR u.last_name LIKE '%" . $value['search_value'] . "%' OR CONCAT_WS( ' ', u.first_name, u.last_name) LIKE  '%" . $value['search_value'] . "%')";
			            } else if ($value['search_field'] == "Processor") {
			                $multi_search .= " (up.first_name LIKE '%" . $value['search_value'] . "%' OR up.last_name LIKE '%" . $value['search_value'] . "%' OR CONCAT_WS( ' ', up.first_name, up.last_name) LIKE  '%" . $value['search_value'] . "%')";
			            } else if ($value['search_field'] == "ID") {
			                $multi_search .= " (form.ID = " . $value['search_value'] . ")";
			            } else {
			            	if($value['search_operator']=="%"){
			            		$multi_search .= " (form.". $value['search_field'] ." LIKE '%" . $value['search_value'] . "%')";
			            	}else{
			            		$multi_search .= " (form.". $value['search_field'] ." ". $value['search_operator'] ." '" . $value['search_value'] . "')";
			            	}
			            }
			            $multi_search .= " AND ";
					}
				}
				if($ctrSpec>0){
					$multi_search = substr($multi_search, 0,strlen($multi_search)-4);
					$multi_search.= ")";
				}
				$obj['multi_search'] = $multi_search;
			}
			$result = $search->getManyRequest($search_value,$field,$id,$start,10,$obj);

			$countRequest = $result[0][3]['count'];
			if(is_null($countRequest)){
				$countRequest = 0;
			}
			$forms = $db->query("SELECT * FROM tb_workspace WHERE id = {$db->escape($id)}", "row");
			$form_json = json_decode($forms['form_json']);
			$fields_headerObj = $form_json->{'form_json'}->{'collected_data_header_info'}->{'listedchoice'};
			$fields_headerObjType = $form_json->{'form_json'}->{'headerInfoType'};
			$output = array(
					"sEcho" => intval($_POST['sEcho']),
					"iTotalRecords" => $countRequest,
					"iTotalDisplayRecords" => $countRequest,
					"start"=>$start,
					"aaData" => array(),
					"column-sort" => $_POST['column-sort'],
					"column-sort-type" => $_POST['column-sort-type'],
				);
			$getCustomView = $db->query("SELECT * FROM tbcustomview WHERE user_id = $user_id AND form_id = $id ","array");
			//generate print

			$getGeneratePrint = $db->query("SELECT * FROM tb_generate WHERE form_id={$db->escape($id)}","row");
            $getGeneratePrintNumrows = $db->query("SELECT * FROM tb_generate WHERE form_id={$db->escape($id)}","numrows");
            $print_form_id = $getGeneratePrint['id'];

			foreach ($result as $value) {
				$otherFieldsStartPos = 3; // start of index
				$aaData = array();
				$button = "";
                $starred_class = "fa fa-star-o fl-custom-starred";
                $starred = 0;
                if ($value[0]['starred'] > 0) {
                    $starred_class = "fa fl-custom-starred fa-star";
                    $starred = $value[0]['starred'];
                }
                //$button .='<a href="/user_view/workspace?view_type=request&formID=' . $id . '&requestID=' . $value['request_id'] . '&trackNo=' . $value['TrackNo'] . '"><button class="tip fa fa-eye btn-basicBtn fl-basicsecondary-btn padding_5 cursor" style="margin-right:3px" form-id = "' . $id . '" request-id="' . $value['request_id'] . '" data-original-title="View Form"></button></a>';
                $form_name = str_replace(" ", "_",$forms['form_name']);
                //$button .='<button class="fa fa-caret-right" style="background:transparent!important; border: 0!important; font-size:15px;"></button> ';
                $button .= "<input type='checkbox' class='" . $form_name . " css-checkbox' data-form-name='" . $form_name . "' style='margin-top: 5px;margin-right: 10px;' button-action-data='" . $value[2]['buttons'] . "' button-request-id='" . $value['ID'] . "'button-workflow-id='" . $value['Workflow_ID'] . "'  button-requestor-id='" . $value['Requestor'] . "' button-processor-id='" . $value['Processor']."' id='". $value['TrackNo'] ."'><label for='". $value['TrackNo'] ."' class='css-label' style='margin-right:7px;margin-top:-5px;'></label>";
                $button .='<button class="tip ' . $starred_class . ' btn-basicBtn padding_5 cursor fl-basicsecondary-btn starred" style="width: 20px;background:transparent!important; border: 0!important; font-size:15px;" data-id="' . $value['request_id'] . '" id="starred_' . $value['request_id'] . '" data-starred="' . $starred . '" data-original-title="Starred Request"></button>';
                if($getGeneratePrintNumrows>0){
                	$button .='<a class="tip" href="/user_view/workspace?view_type=update&ID=' . $print_form_id . '&formID=' . $id . '&requestID=' . $value['request_id'] . '&trackNo=' . $value['TrackNo'] . '" data-original-title="Print Request"><button class="tip btn-basicBtn padding_5 cursor fl-basicsecondary-btn fa fa-print" style="width: 20px;background:transparent!important; border: 0!important; font-size:15px;"></button></a>';                
                }else{
                	$button .='<a class="tip noCustomPrint" href="#" data-original-title="No Customize Print Available"><button class="tip btn-basicBtn padding_5 cursor fl-basicsecondary-btn fa fa-print" style="width: 20px;background:transparent!important; border: 0!important; font-size:15px;opacity: 0.3;"></button></a>';                
                }
                $button .= '<a class="linkTrigger display" href="/user_view/workspace?view_type=request&formID=' . $id . '&requestID=' . $value['request_id'] . '&trackNo=' . $value['TrackNo'] . '">'."<div class='fl-table-ellip'>".$value['TrackNo']."</div></a>";
              // $button .='<button class="fa fa-comment btn-basicBtn padding_5 fl-basicsecondary-btn cursor showReply tip" data-type="1" data-f-id="' . $id . '" data-id="' . $value['request_id'] . '" data-original-title="Add/View Comments" ></button> ';
                //$button .='<button class="tip fa fa-book btn-basicBtn padding_5 fl-basicsecondary-btn cursor viewAuditLogs" style="margin-right:3px" data-request-id="' . $value['request_id'] . '" data-form-id="' . $id . '" data-original-title="Audit Logs"></button>';
                if ($value[2]['buttons'] != '' && $value[2]['buttons'] != 'null' && $value[2]['buttons'] != null) {
                    //$button .= "<button class='tip fa fa-gear btn-basicBtn padding_5 fl-basicsecondary-btn cursor' button-action-data='" . $value[2]['buttons'] . "' button-request-id='" . $value['ID'] . "'button-workflow-id='" . $value['Workflow_ID'] . "'  button-requestor-id='" . $value['Requestor'] . "' button-processor-id='" . $value['Processor'] . "' button-type='action' data-original-title='Please select an Action'></button>";
                }
                //reorder
				if(count($getCustomView)>0){
					// $customViewObject = json_decode($getCustomView[0]['json'],true);
					$customViewObject = getValidHeaderFields($fields_headerObj,$getCustomView,	$fields_headerObjType);
					array_push($aaData, $button);
					foreach ($customViewObject as  $customView) {
						$vl = $customView['field_name'];
						// if($vl=="TrackNo"){
						// 	array_push($aaData, '<a href="/user_view/workspace?view_type=request&formID=' . $id . '&requestID=' . $value['request_id'] . '&trackNo=' . $value['TrackNo'] . '">'."<div class='fl-table-ellip'>".$value['TrackNo']."</div></a>");
						// }else if($vl!=""){
							array_push($aaData, "<div class='fl-table-ellip'>".$value[''. $vl .'']."</div>");
						// }
					}
					
				}else{
					//default column
					$aaData = array($button, 
								// '<a href="/user_view/workspace?view_type=request&formID=' . $id . '&requestID=' . $value['request_id'] . '&trackNo=' . $value['TrackNo'] . '">'."<div class='fl-table-ellip'>".$value['TrackNo']."</div></a>",
								"<div class='fl-table-ellip'>". $value['TrackNo']."</div>",
								"<div class='fl-table-ellip'>". $value['requestorName']."</div>",
								"<div class='fl-table-ellip'>".$value['form_status']."</div>",
								"<div class='fl-table-ellip'>".$value['DateCreated']."</div>",
								
						);
					//push to array $aadata in specific location
					foreach($fields_headerObj as $fields_header) {
						if($value[''. $fields_header->{'field_name'} .'']==""){
							array_insert($aaData,"",$otherFieldsStartPos);
						}else{
							array_insert($aaData, "<div class='fl-table-ellip'>".$value[''. $fields_header->{'field_name'} .'']."</div>",$otherFieldsStartPos);
						}
    				 $otherFieldsStartPos++;
    				}


					//Updated by AARON TOLENTINO
        			// - For having a specific and default header information
					if($fields_headerObjType=="1"){
						$aaData = array($button);
						foreach($fields_headerObj as $fields_header) {
							if($value[''. $fields_header->{'field_name'} .'']==""){
								array_push($aaData,"");
							}else{
								array_push($aaData, "<div class='fl-table-ellip'>".$value[''. $fields_header->{'field_name'} .'']."</div>");
							}
		                }
					}else if($fields_headerObjType=="0"){
						// FOR DEFAULT COLUMN
			            $aaData = array($button, 
								// '<a href="/user_view/workspace?view_type=request&formID=' . $id . '&requestID=' . $value['request_id'] . '&trackNo=' . $value['TrackNo'] . '">'."<div class='fl-table-ellip'>".$value['TrackNo']."</div></a>",
								"<div class='fl-table-ellip'>". $value['TrackNo']."</div>",
								"<div class='fl-table-ellip'>". $value['requestorName']."</div>",
								"<div class='fl-table-ellip'>".$value['form_status']."</div>",
								"<div class='fl-table-ellip'>".$value['DateCreated']."</div>",
								
						);
			        }
				}
				$output['aaData'][] = $aaData;
			}
			echo json_encode($output);
			break;
		case "getOrgchart":
			$search_value = $_POST['search_value'];
			$start = $_POST['start'];
			$result = $search->getOrgchart($search_value,$start);
			echo json_encode($result);
			break;
		case "getOrgchartDataTable":
			$search_value = $_POST['search_value'];
			$start = $_POST['iDisplayStart'];
			$json = array("column-sort"=>$_POST['column-sort'],"column-sort-type"=>$_POST['column-sort-type']);
			$result = $search->getOrgchart($search_value,$start,$json);
			$countOrgchart = count($search->getOrgchart($search_value,""));
			$output = array(
				"sEcho" => intval($_POST['sEcho']),
				"iTotalRecords" => $countOrgchart,
				"iTotalDisplayRecords" => $countOrgchart,
				"start"=>$start,
				"aaData" => array(),
			);
			foreach ($result as $value) {
				$button = "";
				$pushArray = array();
				$button = '<a href="/user_view/organizational_chart?view_type=edit&id=' . $value['id'] . '" class="tip cursor" data-original-title="Edit ' . $value['title'] . '" data-placement="top" id="" data-orgchart-id="" style="margin-right:3px"><i class="fa fa-pencil-square-o tip" data-placement="top" data-original-title="Edit"></i></a>
				 			<a class="tip cursor update_status_orgchart" data-original-title="' . $fs->getStatus_revert($value['status']) . '" data-status="' . $value['status'] . '" data-placement="top" id="" data-id="' . $value['id'] . '" style="margin-right:3px"><i class="fa fa-globe tip" data-placement="top" data-original-title="Deactivate"></i></a>
				 			<a class="tip cursor delete_orgchart" data-original-title="Delete Orgchart" data-placement="top" id="" data-id="' . $value['id'] . '"><i class="fa fa-trash-o tip" data-placement="top" data-original-title="Delete"></i></a>';
				$pushArray[] = $button;
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['title']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['description']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $fs->getStatus($value['status'])."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['date']."</div>";
				$output['aaData'][] = $pushArray;
			}
			echo json_encode($output);
			break;
		case "getForm":
			$search_value = $_POST['search_value'];
			$start = $_POST['start'];
			$result = $search->getForms($search_value,$start);
			echo setAdminViewer($result);
			break;
		case "getFormDataTable":
			$search_value = $_POST['search_value'];
			$start = $_POST['iDisplayStart'];
			$json = array("column-sort"=>$_POST['column-sort'],"column-sort-type"=>$_POST['column-sort-type']);
			$result = $search->getForms($search_value,$start,$json);
			$result2 = json_decode(setAdminViewer($result),true);
			$countForm = $search->getForms($search_value,"");
			$countForm = count(json_decode(setAdminViewer($countForm),true));
			$output = array(
				"sEcho" => intval($_POST['sEcho']),
				"iTotalRecords" => $countForm,
				"iTotalDisplayRecords" => $countForm,
				"start"=>$start,
				"aaData" => array(),
			);
			foreach ($result2 as $value) {
				$button = "";
				$pushArray = array();
				$button = '<a href="/user_view/formbuilder?formID=' . $value['wsID'] . '&view_type=edit" class="tip cursor" data-original-title="Edit" data-placement="top" id="" data-form-id="' . $value['wsID'] . '"><i class="fa fa-pencil-square-o tip" data-placement="top" data-original-title="Edit"></i></a>
 			<a class="tip cursor update_status_form" data-original-title="' . $fs->getStatus_revert($value['ws_status']) . '" data-status="' . $value['ws_status'] . '" data-placement="top" id="" data-id="' . $value['wsID'] . '"><i class="fa fa-globe tip" data-placement="top" data-original-title="Deactivate"></i></a>
 			<a class="tip cursor delete_form" data-original-title="Delete Form" data-form-id="' . $value['wsID'] . '"><i class="fa fa-trash-o tip" data-placement="top" data-original-title="Delete"></i></a>';
				$pushArray[] = $button;
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['form_name']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['form_description']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $fs->getStatus($value['ws_status'])."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['date_created']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['date_updated']."</div>";
				$output['aaData'][] = $pushArray;
			}
			echo json_encode($output);
			break;
		case "getWorkflow":
			$search_value = $_POST['search_value'];
			$start = $_POST['start'];
			$result = $search->getWorkflows($search_value,$start);
			// echo json_encode($result);
			echo setAdminViewer($result);
            break;
		case "getWorkflowDataTable":
			$search_value = $_POST['search_value'];
			$start = $_POST['iDisplayStart'];
			$json = array("column-sort"=>$_POST['column-sort'],"column-sort-type"=>$_POST['column-sort-type']);
			$countworkflow = $search->getWorkflows($search_value,"");
			$countworkflow = count(json_decode(setAdminViewer($countworkflow),true));
			$result = $search->getWorkflows($search_value,$start,$json);
			// echo json_encode($result);
			$result2 = json_decode(setAdminViewer($result),true);
			$output = array(
				"sEcho" => intval($_POST['sEcho']),
				"iTotalRecords" => $countworkflow,
				"iTotalDisplayRecords" => $countworkflow,
				"start"=>$start,
				"aaData" => array(),
			);
			foreach ($result2 as $value) {
				$button = "";
				$pushArray = array();
				$button = '<a href="/user_view/workflow?view_type=edit&form_id=' . $value['form_id'] . '&id=' . $value['wf_id'] . '" class="tip cursor" data-original-title="Edit ' . $value['wf_title'] . '" data-placement="top" id="" data-orgchart-id=""><i class="fa fa-pencil-square-o tip" data-placement="top" data-original-title="Edit"></i></a>
 			<a class="tip cursor update_status_workflow" data-original-title="' . $fs->getStatus_revert($value['Is_Active']) . '" data-status="' . $value['Is_Active'] . '" data-placement="top" id="" data-id="' . $value['wf_id'] . '"><i class="fa fa-globe tip" data-placement="top" data-original-title="Deactivate"></i></a>
 			<a class="tip cursor delete_workflow" data-original-title="Delete Workflow" data-placement="top" id="" data-id="' . $value['wf_id'] . '"><i class="fa fa-trash-o tip" data-placement="top" data-original-title="Delete"></i></a>';
				$pushArray[] = $button;
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['wf_title']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['form_name']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $fs->getStatus($value['Is_Active'])."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['wf_date']."</div>";
				$output['aaData'][] = $pushArray;
			}
			echo json_encode($output);
            break;
	    case "getReports":
            $search_value = $_POST['search_value'];
            $start = $_POST['start'];
            $reports = functions::getReports("WHERE title LIKE '%" . $search_value ."%' AND company_id={$db->escape($auth['company_id'])} LIMIT $start ,10");
            
            print_r(json_encode($reports));
	        break;
	    case "getReportsDataTable":
            $search_value = $_POST['search_value'];
            $start = $_POST['iDisplayStart'];
            $orderBy = " ORDER BY date_created DESC";
            if($_POST['column-sort']){
              $orderBy = " ORDER BY ".$_POST['column-sort']." ".$_POST['column-sort-type'];
            }
            $reports = functions::getReports("WHERE title LIKE '%" . $search_value ."%' AND company_id={$db->escape($auth['company_id'])} $orderBy LIMIT $start ,10");
            $countReports = count(functions::getReports("WHERE title LIKE '%" . $search_value ."%' AND company_id={$db->escape($auth['company_id'])}"));
            $output = array(
				"sEcho" => intval($_POST['sEcho']),
				"iTotalRecords" => $countReports,
				"iTotalDisplayRecords" => $countReports,
				"start"=>$start,
				"aaData" => array(),
			);
			$reports = json_decode(json_encode($reports),true);
			foreach ($reports as $value) {
				$button = "";
				$pushArray = array();
				
				$button = '<a href="/user_view/report?id=' . $value['id'] . '&form_id=' . $value['form_id'] . '"><i class="fa fa-pencil-square-o tip" data-placement="top" ></i></a>
 			<a><i class="fa fa-file-text tip" data-placement="top" data-original-title="Generate" link-type="report-generation" data-report-id="' . $value['id'] . '"></i></a>
 			<a><i class="fa fa-globe tip update_status_report" data-placement="top" data-original-title="Delete" data-status="' . $value['is_active'] . '" data-placement="top" id="" data-id="' . $value['id'] . '"></i></a>';
				// $button = '<a><i class="fa fa-globe tip" data-placement="top" data-original-title="Generate" link-type="report-generation" data-report-id="' . $value['id'] . '"></i></a>
 			// <a><i class="fa fa-trash-o tip update_status_report" data-placement="top" data-original-title="Delete" data-status="' . $value['is_active'] . '" data-placement="top" id="" data-id="' . $value['id'] . '"></i></a>';

				$pushArray[] = $button;
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['title']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $fs->getStatus($value['is_active'])."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['date_created']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['date_updated']."</div>";
				$output['aaData'][] = $pushArray;
			}
            print_r(json_encode($output));
	        break;
	    case "getPrintReport";
	    	// $search_value = $_POST['search_value'];
            // $start = $_POST['start'];
            $result = $search->getPrintReports(" WHERE company_id ={$db->escape($auth['company_id'])}");
            echo json_encode($result);
            break;
        case "saveRequestFilter";
        	$search_value = $_POST['search_value'];
            $search_field = $_POST['search_field'];
            $multi_search = $_POST['multi_search'];
            $title = $_POST['title'];
            $form_id = $_POST['form_id'];
            $date_field = $_POST['date_field'];
			$date_from = $_POST['date_from'];
			$date_to = $_POST['date_to'];
            $insert = array("search_value"=>$search_value,
            				"search_field"=>$search_field,
            				"multi_search"=>$multi_search,
            				"title"=>$title,
            				"date_field"=>$date_field,
            				"date_from"=>$date_from,
            				"date_to"=>$date_to,
            				"form_id"=>$form_id,
            				"user_id"=>$user_id);
           	echo $db->insert("tbfilteredCategory",$insert);
           	break;
        case "deleteFilter":
        	$id = $_POST['id'];
        	$delete_id = array("id"=>$id);
        	$db->delete("tbfilteredCategory",$delete_id);
        	break;
        case "saveCustomView":
        	$customView = $_POST['customView'];
        	$form_id = $_POST['form_id'];
        	$fields = array("user_id"=>$user_id,
        					"form_id"=>$form_id,
        					"json"=>$customView);
        	$count = $db->query("SELECT * FROM tbcustomview WHERE user_id = $user_id AND form_id = $form_id ","numrows");
        	if($count>0){
        		$where = array("form_id"=>$form_id,
        						"user_id"=>$user_id);
        		$db->update("tbcustomview",$fields,$where);
        	}else{
        		$db->insert("tbcustomview",$fields);
        	}
        	break;
        case "getCustomizeReportDataTable":
            $search_value = $_POST['search_value'];
            $start = $_POST['iDisplayStart'];
            $reports = $search->getPrintReports("WHERE form_name LIKE '%" . $search_value ."%' AND company_id={$db->escape($auth['company_id'])} LIMIT $start ,10");
            $countReports = count($search->getPrintReports("WHERE form_name LIKE '%" . $search_value ."%' AND company_id={$db->escape($auth['company_id'])}"));
            $output = array(
				"sEcho" => intval($_POST['sEcho']),
				"iTotalRecords" => $countReports,
				"iTotalDisplayRecords" => $countReports,
				"start"=>$start,
				"aaData" => array(),
			);
			$reports = json_decode(json_encode($reports),true);
			foreach ($reports as $value) {
				$button = "";
				$pushArray = array();
				
				$button = '<a href="/user_view/generate?view_type=update&formID=' . $value['id']. '&printID=' . $value['form_id'].'"><i class="fa fa-pencil-square-o tip" data-placement="top" ></i></a>
 			<a><i class="fa fa-trash-o tip delete_printReport" data-placement="top" data-original-title="Delete" data-status="' . $value['is_active'] . '" data-placement="top" id="" data-id="' . $value['id'] . '"></i></a>';
				// $button = '<a><i class="fa fa-globe tip" data-placement="top" data-original-title="Generate" link-type="report-generation" data-report-id="' . $value['id'] . '"></i></a>
 			// <a><i class="fa fa-trash-o tip update_status_report" data-placement="top" data-original-title="Delete" data-status="' . $value['is_active'] . '" data-placement="top" id="" data-id="' . $value['id'] . '"></i></a>';

				$pushArray[] = $button;
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['form_name']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['form_description']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $fs->getStatus($value['is_active'])."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['date_created']."</div>";
				$pushArray[] = "<div class='fl-table-ellip'>" . $value['date_updated']."</div>";
				$output['aaData'][] = $pushArray;
			}
            print_r(json_encode($output));
	        break;
	}
	
}




?>
